// Created: Dec 14, 2014
//
// Author: wjinwen.1988@gmail.com

#ifndef CHI_NET_TLS_SERVER_H
#define CHI_NET_TLS_SERVER_H

#include <string>
#include <map>

#include <openssl/ssl.h>

#include "chi/net/inet_address.h"
#include "chi/net/tls_connection.h"
#include "chi/net/tcpserver.h"

namespace chi {
namespace net {

class Acceptor;
class EventLoop;
class EventLoopThreadPool;

// TLS服务器封装, 支持单线程和多线程模式。
class TLSServer : public TcpServer {
 public:
  TLSServer(SSL_CTX* ssl_ctx,
            EventLoop* loop, 
            const InetAddress& listenaddr,
            const std::string& name);
  virtual ~TLSServer();

  TLSServer(const TLSServer&) = delete;
  void operator=(const TLSServer&) = delete;

 protected:
  virtual void NewConnection(int sockfd, const InetAddress& peeraddr);
 private:
  SSL_CTX* ssl_ctx_;  // openssl context
};

}  
}

#endif
